//
//  AppDelegate.m
//  XMJJ_zmy
//
//  Created by 丁浩 on 2025/7/3.
//

#import "AppDelegate.h"
#import "XMTabBaseViewController.h"
#import <WXApi.h>

@interface AppDelegate ()<WXApiDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [self creatRootView];
    return YES;
}

- (void)creatRootView {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    XMTabBaseViewController *rootVC = [[XMTabBaseViewController alloc] init];
    self.window.rootViewController = rootVC;
    [WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString * _Nonnull log) {

    }];
//    [WXApi registerApp:AppId universalLink:UniversalLink];
//    [WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult * _Nonnull result) {
//
//    }];
    [self.window makeKeyAndVisible];
}

- (BOOL)application:(UIApplication *)application
            openURL:(nonnull NSURL *)url
            options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    XMBaseViewController *currentVC = (XMBaseViewController *)[AppDelegate getCurrentVC];
    
    UIAlertController *alertVC = [UIAlertController initwithTitle:url.absoluteString message:@"" titles:@[@"确定", @"取消"] alertStyle:UIAlertControllerStyleAlert itemSelect:^(NSInteger selectIndex) {
        
    }];
    [currentVC presentViewController:alertVC animated:YES completion:nil];
    
    return [WXApi handleOpenURL:url delegate:(id<WXApiDelegate>)currentVC];
}


#pragma mark - UISceneSession lifecycle


//- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
//    // Called when a new scene session is being created.
//    // Use this method to select a configuration to create the new scene with.
//    return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
//}
//
//
//- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
//    // Called when the user discards a scene session.
//    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
//    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
//}


@end
